<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.sql.*" %>
<%@ page import="com.model.*" %>
<!DOCTYPE html PUBLIC "-//W3C//Dtd XHTML 1.0 Transitional//EN" "http://www.w3.org/tr/xhtml1/Dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<style type="text/css">
<!--
body {
	background-color: #fff;
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
.tabfont01 {	
	font-family: "宋体";
	font-size: 9px;
	color: #555555;
	text-decoration: none;
	text-align: center;
}
.font051 {font-family: "宋体";
	font-size: 12px;
	color: #333333;
	text-decoration: none;
	line-height: 20px;
}
.font201 {font-family: "宋体";
	font-size: 12px;
	color: #FF0000;
	text-decoration: none;
}
.button {
	font-family: "宋体";
	font-size: 14px;
	height: 37px;
}
html { overflow-x: auto; overflow-y: auto; border:0;} 
-->
</style>

<link href="../css/css.css" rel="stylesheet" type="text/css" />
<script type="text/JavaScript">

</script>
<link href="../css/style.css" rel="stylesheet" type="text/css" />
</head>
<SCRIPT language=JavaScript>
function sousuo(){
	window.open("gaojisousuo.htm","","depended=0,alwaysRaised=1,width=800,height=510,location=0,menubar=0,resizable=0,scrollbars=0,status=0,toolbar=0");
}
function selectAll(){
	var obj = document.fom.elements;
	for (var i=0;i<obj.length;i++){
		if (obj[i].name == "delid"){
			obj[i].checked = true;
		}
	}
}

function unselectAll(){
	var obj = document.fom.elements;
	for (var i=0;i<obj.length;i++){
		if (obj[i].name == "delid"){
			if (obj[i].checked==true) obj[i].checked = false;
			else obj[i].checked = true;
		}
	}
}
</SCRIPT>

<body>
<%
	request.setCharacterEncoding("UTF-8");
	response.setCharacterEncoding("UTF-8");

	Connection con = DataBase.getConnection();

	//TODO: rewrite the sql clause
	PreparedStatement pstmtInfo = con.prepareStatement("SELECT * FROM item WHERE iid=?");
	PreparedStatement pstmtHistory = con.prepareStatement("SELECT * FROM item_history WHERE iid=? ORDER BY time DESC");
	String iid = request.getParameter("iid");
	pstmtInfo.setString(1, iid);
  	ResultSet rsInfo = pstmtInfo.executeQuery();
  	if( !rsInfo.next() )
  	{%>
	无效物品！请勿做非法输入！
	<%}
  	else{
  		String store=rsInfo.getString("store");
  		pstmtHistory.setString(1, iid);
  		ResultSet rsHistory = pstmtHistory.executeQuery();
  	%>
<form name="fom" id="fom" method="post">
<table width="100%" border="0" cellspacing="0" cellpadding="0">

  <tr>
    <td height="30">      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td>
		   <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
		    <tr>
			  <td width="21">&nbsp;</td>
			  </tr>
          </table></td>
        </tr>
    </table></td></tr>
  <tr>
    <td><table id="subtree1" align="center" style="DISPLAY: " width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td><table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
         
              <tr>
                <td height="40" class="font42"><table width="100%" border="0" cellpadding="4" cellspacing="1" bgcolor="#464646" class="newfont03">
                    <tr>
                    <td height="20" colspan="4" align="center" bgcolor="#EEEEEE"class="tablestyle_title">物品详细信息</td>
                    </tr>
                  <tr>
				    <td width="16%" height="20" align="right" bgcolor="#FFFFFF">物品名称:</td>
                    <td width="34%" bgcolor="#FFFFFF"><%=rsInfo.getString("name") %></td>
				    <td width="16%" height="20" align="right" bgcolor="#FFFFFF">物品品牌:</td>
				    <td width="34%" colspan="1" bgcolor="#FFFFFF"><%=rsInfo.getString("brand") %></td>
                    </tr>
                  <tr>
				    <td height="20" align="right" bgcolor="#FFFFFF">库存数量:</td>
				    <td bgcolor="#FFFFFF"><%=rsInfo.getString("amount")+" "+rsInfo.getString("unit") %></td>
				    <td height="20" align="right" bgcolor="#FFFFFF">存放位置:</td>
				    <td colspan="1" bgcolor="#FFFFFF"><%=rsInfo.getString("store") %></td>
                    </tr>
                  <tr>
                    <td height="20" align="right" bgcolor="#FFFFFF">管理员:</td>
                    <td bgcolor="#FFFFFF"><%=rsInfo.getString("person") %></td>
                    <td height="20" align="right" bgcolor="#FFFFFF">备注:</td>
                    <td colspan="1" bgcolor="#FFFFFF"><%=rsInfo.getString("description") %></td>
                  </tr>
               
                  <tr >
				    <td height="85" align="right" bgcolor="#FFFFFF">出入库记录:</td>
				    <td colspan="3" bgcolor="#FFFFFF"><table width="100%" align="center" border="0" cellpadding="4" cellspacing="1" bgcolor="#464646">
                    <tr height="10" align="center" bgcolor="#FFFFFF"><td width="13%">时间</td><td width="13%">数量</td><td width="13%">从</td><td width="13%">到</td><td width="13%">经手人</td><td width="13%">进出情况</td><td>备注</td></tr>
                    <%
                    	while(rsHistory.next()) {
                    		%>
                    		<tr height="20" bgcolor="#FFFFFF">
                    		<td><%=rsHistory.getTimestamp("time") %></td>
                    		<td><%=(rsHistory.getDouble("number")>0)?rsHistory.getString("number"):rsHistory.getString("number").substring(1) %></td>
                    		<td><%=rsHistory.getString("from")==null?"":rsHistory.getString("from") %></td>
                    		<td><%=rsHistory.getString("to")==null?"":rsHistory.getString("to") %></td>
                    		<td><%=rsHistory.getString("person") %></td>
                    		<td><%=(rsHistory.getDouble("number")>0)?"入库"+rsHistory.getString("number")+rsInfo.getString("unit"):"出库"+rsHistory.getString("number").substring(1)+rsInfo.getString("unit") %></td>
                    		<td><%=rsHistory.getString("remark") %></td>
                    		</tr>
                    		<%
                    	}
                    %></table></td>
                    </tr>
                </table></td>
              </tr>
            </table></td>
        </tr>
      </table>
      <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td height="6"><img src="../images/spacer.gif" width="1" height="1" /></td>
        </tr>
        <tr>
          <td height="33"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="right-font08">
              <tr>
                <td width="1%"><table width="20" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                    </tr>
                </table></td>
              </tr>
          </table></td>
        </tr>
      </table></td>
  </tr>
  		<tr>
			<td colspan="2" align="center" height="50px">
			<input style="height:20px;" type="button" name="Submit2" value="返回" class="button" onclick="window.history.go(-1);"/></td>
		</tr>
</table>
</form>
<%
		rsHistory.close();
	}
	rsInfo.close();
	con.close();
%>
</body>
</html>
